import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-09-23
 * Time: 18:31
 */
public class Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //楼梯最高层
        int n = in.nextInt();
        int[] cost = new int[n];
        for(int i = 0; i < n; i++) {
            cost[i] = in.nextInt();
        }
        if(n == 1) {
            System.out.println(0);
            return;
        }
        //定义一个数组表示到达第i层最少花费
        int[] min = new int[n];
        min[0] = cost[0];
        min[1] = cost[1];
        for(int i = 2; i < n; i++) {
            min[i] = Math.min(min[i-1],min[i-2] + cost[i]);
        }
        System.out.println(Math.min(min[n-1],min[n-2]));
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int leng = in.nextInt();
        in.nextLine();
        String str1 = in.next();
        in.next();
        String str2 = in.nextLine();
        String[] strs = new String[leng];
        for (int i = 0; i < leng; i++) {
            strs[i] = in.nextLine();
        }
        System.out.println("=====================");
        System.out.println(leng);
        System.out.println(str1);
        System.out.println(str2);
        for (int i = 0; i < leng; i++) {
            System.out.print(strs[i] + " ");
        }
    }
}
